/**
 * 会议列表
 */
const APIError = require('../middlewares/result.js').APIError;
const ApiErrorNames = require('../config/ApiErrorNames.js');
const { DataTypes, Op } = require('sequelize');
const sequelize = require('../config/sequlieze.js');

const Article = sequelize.define(
  'Article',
  {
    articleId: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    title: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    accessPath: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    creator: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  },
  {
    tableName: 'Articles',
    paranoid: true, // 软删除
  }
);

Article.sync({ alter: true }); // 检查数据库中表的状态，然后进行必要的更改以使其与模型匹配

// 创建
const create = async (creator, articleId, title, accessPath) => {
  console.log(creator, articleId, title, accessPath)
  // 存储文章id和相对路径
  let result = await Article.create({
    creator,
    articleId,
    title,
    accessPath
  });
  return result;
};



module.exports = {
  create,
};
